<?php

class UserglodController extends YzwController{
	//去调用淘宝API，然后销量对比，然后给用户扣款
	public function actionDeduction(){
		//这里取所有还没有结算清楚的
		$time = time();
		$objCriteria = new CDbCriteria(array(
			'condition' => "status = 1 AND is_complete = 0 AND start_time <= {$time}",
			'select' => '*',
			//'select' => 'goods_id,uid,end_time,sales,product_id,promo_price',
		));
		$models = GoodsBmModel::model()->findAll($objCriteria);
		foreach($models as $model){
			$data = TaobaoApi::getInstance()->getItem($model->product_id);
			if(!empty($data)){
				if($model->deduction($data['sales'])){
					//扣完款了后判断是否是需要发短信什么的。
				}
			}
		}
	}
}